<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>待处理</title>
<link rel="stylesheet" th:href="@{/layui/css/layui.css}">
</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div data-th-replace="~{layout :: header}"></div>
		<div class="layui-body" style="left: 10px; top: 10px">
			<div style="margin-bottom: 15px;">
				<a class="layui-btn" th:href="@{/building_back/list}">待处理</a>
				<a class="layui-btn layui-btn-primary" th:href="@{/building_back/list?deal=true}">已处理</a>
			</div>
			<!-- 内容主体区域 -->
			<div>
				<form id="searchFrom" class="layui-form layui-form-pane"
					th:action="@{/building_back/list}" method="post">
					<div class="layui-form-item">
						<label class="layui-form-label">小区名称</label>
						<div class="layui-inline">
							<div class="layui-input-inline">
								<input name="villageName" placeholder="小区名称" class="layui-input"
									th:value="${villageName != null ? villageName : ''}" maxlength="30">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">提交缺失地址</label>
							<div class="layui-input-inline">
								<input name="key" placeholder="提交缺失地址" class="layui-input"
									th:value="${key != null ? key : ''}" maxlength="30">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">提交时间</label>
							<div class="layui-input-inline" style="width: 300px;">
								<input id="createTime" name="createTime" placeholder="提交时间-开始 至 提交时间-截至" class="layui-input"
									th:value="${createTime != null ? createTime : ''}" maxlength="30">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">提交人</label>
							<div class="layui-input-inline">
								<input name="createUser" placeholder="提交人" class="layui-input"
									th:value="${createUser != null ? createUser : ''}" maxlength="30">
							</div>
						</div>
						<button type="submit" class="layui-btn">查询</button>
					</div>
				</form>
			</div>
			<table class="layui-table">
				<colgroup>
					<col width="100">
					<col width="120">
					<col>
					<col width="180">
					<col width="180">
					<col width="120">
				</colgroup>
				<thead>
					<tr>
						<th><b>顺序号</b></th>
						<th><b>小区名称</b></th>
						<th><b>提交缺失地址</b></th>
						<th><b>提交人（用户名片ID）</b></th>
						<th><b>提交时间</b></th>
						<th><b>操作</b></th>
					</tr>
				</thead>
				<tbody>
					<tr data-th-each="item, iterStat : ${datas}">
						<td data-th-text="${iterStat.count}+${pageIndex-1}*${pageSize}"></td>
						<td data-th-text="${item.villageName}"></td>
						<td data-th-text="${item.address}"></td>
						<td data-th-text="${item.userName}"></td>
						<td data-th-text="${item.createTime}" class="date"></td>
						<td><a class="layui-btn layui-btn-xs"
							th:onclick="'javascript:deal(' + ${item.id} + ');'">处理</a></td>
					</tr>
				</tbody>
			</table>

			<div id="pageContent"></div>
		</div>

		<div class="layui-footer">
			<!-- 底部固定区域 -->

		</div>
	</div>
	<!-- <script src="/layui/jquery.min.js"></script>
<script src="/layui/layui.js"></script> -->
	<script th:inline="javascript">
//JavaScript代码区域
var contextRoot = /*[[@{/}]]*/ '';
layui.use('laypage', function(){
  var laypage = layui.laypage;
  //执行一个laypage实例
  laypage.render({
	  elem: 'pageContent'
	  ,count:[[${total}]] //数据总数，从服务端得到
	  ,curr: [[${pageIndex}]]	
	  ,layout:['count','prev', 'page', 'next','skip']
	  ,jump: function(obj, first){
		  console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
		  console.log(obj.limit); //得到每页显示的条数
	    //首次不执行
	   if(!first || [[${pageIndex}]] != obj.curr){
	      window.location.href = contextRoot+'/building_back/list?pageIndex=' + obj.curr + "&pageSize=" + obj.limit +
	    		  "&" + $("#searchFrom").serialize();
	    } 
	  }
	}); 
});
layui.use('laydate', function() {
	var laydate = layui.laydate;
	laydate.render({
		elem : '#createTime' //指定元素
		,format:'yyyy-MM-dd HH:mm:ss'
		,type:'datetime'
		,min: '2018-1-1'
		,max: '3000-1-1'
		,theme: '#698B69'
		,range:"至"
		,calendar: true
		 
	});
});
function deal(id){
	layer.open({
		type: 2,
		resize:false,
		title: "楼盘地址反馈详情",
		area: ['90%','90%'],
		content: contextRoot+"/building_back/show_view?deal=true&id=" + id, //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
		btn:['保存','取消'],
		yes:function(index){
			details(index);
		},
		cancel:function(){}
	});
}
function details(index){
	var obj = $("iframe").contents().find("#addForm").serialize();
	$.ajax({
		type : "POST",
		data : obj,
		url : contextRoot+"/building_back/deal",
		dataType : "json",
		success : function(msg) {
			console.log(msg);
			if (msg.meta.code == 0) {
				layer.msg("操作成功!");
				layer.close(index);
				window.location.reload();
			} else {
				layer.msg(msg.meta.message);
			}
		}
	});
}
</script>
</body>
<script type="text/javascript" th:src="@{/common.js}"></script>
</html>